package decisionalalgorithms.guialgorithms.converters;

import com.sun.istack.Nullable;
import decisionalalgorithms.guialgorithms.commands.InitMatrixCommand;
import decisionalalgorithms.guialgorithms.domain.InitMatrix;
import lombok.Synchronized;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class InitMatrixToInitMatrixCommand implements Converter<InitMatrix, InitMatrixCommand> {
    @Synchronized
    @Nullable
    @Override
    public InitMatrixCommand convert(InitMatrix source) {
        if (source == null) {
            return null;
        }
        final InitMatrixCommand initMatrixCommand = new InitMatrixCommand();
        initMatrixCommand.setId(source.getId());
        initMatrixCommand.setAlgorithm(source.getAlgorithm());
        initMatrixCommand.setMatrixBuildDetails(source.getMatrixBuildDetails());
        return initMatrixCommand;
    }
}
